/*
 *  Author: Sinclair Ross
 *  Date: 29/04/2014
 *  Description: 
 *
 *
 *
 */

package com.forbiddendesert.master;

import com.forbiddendesert.logic.GameLogic;

import android.content.Context; 
import android.os.Handler; 
import android.os.Message; 
import android.util.Log; 
import android.view.MotionEvent;
  
public class GameThread extends Thread implements Runnable
{ 
    public static String TAG = "DEBUG GameThread"; 
      
    private GameLogic mGameLogic; 
    private boolean mRunning; 
    private boolean mPaused; 
    private Handler mHandler; 
      
    private Long mStartTime; 
    private Long mEndTime; 
    private Long mDeltaTime; 
      
    private Message mMessage; 
  
    public GameThread(Context context, Handler handler, RendererPacket packet, GameLogic gameLogic) 
    { 
        super(); 
        Log.e(TAG,"GameThread"); 
  
        mGameLogic = gameLogic; 
          
        mRunning = true; 
        mHandler = handler; 
    }
      
    @Override 
    public void run() 
    { 
        Log.e(TAG,"Run"); 
        while(mRunning) 
        {  
            if(!mPaused) 
            { 
            	mGameLogic.Update(1l); 
            } 
        } 
    } 
      
    
    public Message composeMessage(int what) 
    { 
        mMessage = Message.obtain(); 
        mMessage.what = what; 
      
        return mMessage; 
    } 
      
    public void pauseThread() 
    { 
        Log.e(TAG,"PauseThread"); 
        mPaused = true; 
    } 
      
    public void resumeThread() 
    { 
        Log.e(TAG,"ResumeThread"); 
        mPaused = false; 
    } 
      
    public void cleanUp() 
    { 
  
    } 
} 